package com.wn.controller;

import com.wn.annotation.RequireRoles;
import com.wn.entity.Guideinfo;
import com.wn.entity.Privatemade;
import com.wn.service.PrivatemadeService;
import com.wn.utils.PageParam;
import com.wn.utils.Rsp;
import com.wn.utils.SystemControllerLog;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * (Privatemade)表控制层
 *
 * @author makejava
 * @since 2020-10-26 09:32:42
 */
@RestController
@RequestMapping("privatemade")
public class PrivatemadeController {
    /**
     * 服务对象
     */
    @Resource
    private PrivatemadeService privatemadeService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Privatemade selectOne(String id) {
        return this.privatemadeService.queryById(id);
    }


    @GetMapping("findDetailById")
    public Map<String,Object> findDetailById(String id) {
        return this.privatemadeService.findDetailById(id);
    }

    @SystemControllerLog(description = "分页查询订制列表")
    @PostMapping("/searchSomePrivatemadeByPage")
    @RequireRoles(roles = {"admin","super_admin","reception","guide","tourist"},index = 1)
    @ApiOperation("查询所有用户 支持 多条件 分页 排序 查询")
    public Rsp searchSomeByPage(@RequestBody PageParam<Privatemade> privatemadePageParam,
        @RequestHeader("token") String token){

        return Rsp.success(privatemadeService.queryAllByLimit(privatemadePageParam));
    }


    @PostMapping("/addOnePrivatemade")
    @RequireRoles(roles = {"admin","super_admin","reception","guide","tourist"},index = 1)
    public Rsp addOne(@RequestBody  Privatemade privatemade){

        return privatemadeService.insert(privatemade);
    }


    @PostMapping("/deletePrivatemadeLogical")
    @RequireRoles(roles = {"admin","super_admin","reception","guide","tourist"},index = 1)
    public Rsp deleteUserLogical(@RequestBody Privatemade privatemade){

        return privatemadeService.deleteLogical(privatemade);
    }


    @PostMapping("/updatePrivatemade")
    @RequireRoles(roles = {"admin","super_admin","reception"},index = 1)
    public Rsp updateUser(@RequestBody Privatemade privatemade){

        return privatemadeService.update(privatemade);
    }

}
